package com.ibeetl.admin.console.service;


import com.ibeetl.admin.console.dao.FiFinItemCheckDetail2Dao;
import com.ibeetl.admin.console.entity.FiFinItemCheckDetail;
import com.ibeetl.admin.console.entity.FiFinItemCheckDetail2;


import com.ibeetl.admin.console.web.dto.JGHZExcelImportData;
import com.ibeetl.admin.console.web.dto.KMHZExcelImportData;
import com.ibeetl.admin.core.service.CoreBaseService;
import com.ibeetl.admin.core.util.PlatformException;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;






/**
 * FiFinItemCheckDetail2 Service
 */

@Service
@Transactional
public class FiFinItemCheckDetail2Service extends CoreBaseService<FiFinItemCheckDetail2>{

    @Autowired
    private FiFinItemCheckDetail2Dao fiFinItemCheckDetail2Dao;

    public PageQuery<FiFinItemCheckDetail2>queryByCondition(PageQuery query){
        PageQuery ret =  fiFinItemCheckDetail2Dao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelFiFinItemCheckDetail2(List<Long> ids){
        try {
            fiFinItemCheckDetail2Dao.batchDelFiFinItemCheckDetail2ByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除FiFinItemCheckDetail2失败", e);
        }
    }
    public List<KMHZExcelImportData> queryExcel(PageQuery<FiFinItemCheckDetail2> query) {
        PageQuery<FiFinItemCheckDetail2> ret = fiFinItemCheckDetail2Dao.queryByCondition(query);
        List<FiFinItemCheckDetail2> list = ret.getList();
        List<KMHZExcelImportData> items = new ArrayList<>();
        for(FiFinItemCheckDetail2 user:list) {
            KMHZExcelImportData userItem = new KMHZExcelImportData();
            userItem.setManageCom(user.getManageCom());
            userItem.setCodename(user.getCodename());
            userItem.setBuType(user.getBuType());
            userItem.setAccountCode(user.getAccountCode());
            userItem.setAccountcodename(user.getAccountcodename());
            userItem.setFinItemType(user.getFinItemType());
            userItem.setcActuMoney(user.getCActuMoney());
            userItem.setfMoney(user.getFMoney());
            userItem.setDifMoney(user.getDifMoney());
//            CoreDict dict = dictService.findCoreDict(CoreDictType.USER_STATE,user.getState());
//            userItem.setStateText(dict.getName());
//
//            if(StringUtils.isNotEmpty(user.getJobType1())){
//                dict = dictService.findCoreDict("job_type",user.getJobType1());
//                userItem.setJobType1Text(dict.getName());
//            }
//
//            String orgName = orgRoot.findChild(user.getOrgId()).getName();
//            userItem.setOrgText(orgName);
            items.add(userItem);

        }
        return items;

    }
}